﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Cit.CDE.Net.Module;
using Cit.CDE.Net.Module.Commons;
using cde.SystemCommon;
using ConfigAndElse;
using System.Text;
using cde.UserControl;
using System.IO;
using System.Xml;
using Module;
using Cit.CDE.Net.Service.ModuleFactory;
using Cit.CDE.Net.Service;
using UserControl;
using System.Timers;
using System.Data.SqlClient;
using Cit.CDE.ApplicationBlocks.Data;
using Cit.CDE.Net.Service.DataAccess;
using System.Reflection;

/// <summary>
/// Copyright (C)   jinggubang
/// FileName:        main_main_MasterPage.aspx.cs         
/// Author :         fengsen
/// CDT:             2011-12-14           
/// Version:         1.0.0.0                
/// Depiction:       母版页    
/// </summary>
public partial class main_main_MasterPage : System.Web.UI.MasterPage
{
    /// <summary>
    /// EntityManager
    /// </summary>
    private CDEEntityManager em;
    /// <summary>
    /// 查询条件
    /// </summary>
    public CDESearchCriteria sc;
    /// <summary>
    /// 所有页
    /// </summary>
    public string strAllPage = string.Empty;
    /// <summary>
    /// 当前页
    /// </summary>
    public string strCurPage = string.Empty;
    /// <summary>
    /// 初始页
    /// </summary>
    public int intPageNo = 0;
    /// <summary>
    /// 选择列表
    /// </summary>
    public List<int> listIndex;
    /// <summary>
    /// 选择数据id列表
    /// </summary>
    private List<string> listID = new List<string>();
    /// <summary>
    /// 标题CheckBox表示Flg
    /// </summary>
    public string strHc = string.Empty;
    /// <summary>
    /// 序号
    ///  <summary>
    protected int _Num_HH;
    /// <summary>
    /// EntityManager name
    /// </summary>
    public string EM;

    /// <summary>
    /// 查询按钮显示Flg
    /// </summary>
    public string strQry = string.Empty;
    /// <summary>
    /// 初始化
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        //为js文件注册id
        Page.ClientScript.RegisterArrayDeclaration("IDArray", 
            string.Format("'{0}','{1}','{2}','{3}'", 
              this.hidEnName.ClientID, 
              this.hidDeAjaxDdlValue.ClientID,
              this.hidChooseValue.ClientID,
              this.hidSupCustomer.ClientID)); 


        //EEntityManager名字
        EM = Request.QueryString[WEBConstants.EM_QUERY_STRING];
        //初始化EM
        if (!Cit.CDE.Net.Module.Commons.CDEConstants.IsEmpty(EM))
        {
            em = cde.cache.CDEFactory.getEMByFullName(EM);
        }
        else
        {
            em = null;
        }
        em.Resource_manager = Resources.ResourceErrMsg.ResourceManager;
        //查询条件绑定em
        dgSearch.EntityManager = em;
        //结果显示列表绑定em
        dgmeisai.EntityManager = em;
        //为em设定隐藏值
        this.hidEnName.Value = em.Full_Name;
        //设定跳转画面路径
        if (SystemConfig.Config.ContainsKey(em.Full_Name))
        {
            this.hidUrl.Value = SystemConfig.Config[em.Full_Name];
        }
        else
        {
            this.hidUrl.Value = string.Empty;
        }

        

        if (!IsPostBack)
        {
            //页设置
            this.setPagesize();

            string ids;

            //初始化查询条件
            CDESearchCriteria backSc = (CDESearchCriteria)Session[WEBConstants.SC_SESSION_ID + EM];
            //是否返回
            if ((string)Request[CDEConstants.CONST_QUERYSTRING_IS_BACK_SC] == "1" && backSc != null && backSc.EntityManager.Id == em.Id)
            {
                sc = backSc;
                //多级联动em
                hidDeAjaxDdlValue.Value = (string)Session[WEBConstants.SC_SESSION_ID + EM + "DEA"];
                //手动添加选择按钮
                hidSupCustomer.Value = (string)Session[WEBConstants.SC_SESSION_ID + EM + "CHO"];
                //页数
                intPageNo = sc.PageStart / sc.PageSize;
                //显示条数设定
                for (int i = 0; i < ddlPageCount.Items.Count; i++)
                {
                    ListItem item = ddlPageCount.Items[i];

                    if (item.Value.Equals(sc.PageSize.ToString()))
                    {
                        ddlPageCount.SelectedIndex = i;
                        break;
                    }
                }
            }
            else
            {
                ids = (string)Session[CDEConstants.CONST_SESSION_STRUCT_ITEM_IDS];
                
                if (ids != null && ids != string.Empty)
                {
                    sc.addCondition("ID", ids, CDEConstCompare.Include);
                }
                if (ddlPageCount.Items.Count > 0)
                {
                    ddlPageCount.SelectedIndex = 0;
                }

                //子画面传过来的条件
                GetSubScCondition();
            }

            //  //子画面传过来的条件
            //GetSubScCondition();


            //数据绑定
            SearchDataBind();

            //结果显示
            refreshResult();
        }
        else
        {
            //查询条件
            sc = (CDESearchCriteria)Session[WEBConstants.SC_SESSION_ID + EM];

            //所有选择行ID
            listIndex = new List<int>();
            for (int index = dgmeisai.Items.Count - 1; index > -1; index--)
            {
                DataGridItem tr = dgmeisai.Items[index];

                HtmlInputCheckBox chk = (HtmlInputCheckBox)tr.Cells[0].FindControl("chkMeisai");
                
                if (chk.Checked)
                {
                    listIndex.Add(index);
                    listID.Add(chk.Value);
                }
            }
            //设定控件数据源
            dgmeisai.ListEntity = (List<CDEEntity>)Session[WEBConstants.LIST_SESSION_ID + EM];
            //设置页面序号
            GetFirstNum();
            //控件数据绑定
            dgmeisai.DataBind();
            //结果显示
            //refreshResult();
        }
        //下拉检索条件初始化
        initDEData(em);
        this.dgSearch.GridLines = GridLines.None;
    }
    /// <summary>
    /// 数据绑定
    /// </summary>
    protected void SearchDataBind()
    {
        dgSearch.Search_Criteria = sc;
        dgSearch.DataBind();
    }

    /// <summary>
    /// 查询
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void cmdKen_Click(object sender, EventArgs e)
    {
        this.intPageNo = 0;
        Session[WEBConstants.PAGE_NO_SESSION_ID + EM] = this.intPageNo.ToString();
        //sc = this.CreatSc(em);
        //查询条件
        sc = new CDESearchCriteria(em);
        //sc.setSystemDefaultValue((Oprator)Session[CDEConstants.SESSION_LOIN_OPRATOR]);
        //排序
        sc.setSystemDefaultSort();
        string ids;
        ids = (string)Session[CDEConstants.CONST_SESSION_STRUCT_ITEM_IDS];
        if (ids != null && ids != string.Empty)
        {
            sc.addCondition("ID", ids, CDEConstCompare.Include);
        }

        sc.setHiddenDefaultValue(em, (Oprator)Session[CDEConstants.SESSION_LOIN_OPRATOR]);

        //子画面传过来的条件
        GetSubScCondition();

        dgSearch.setScFromRequest(sc, Request.Form);

        SearchDataBind();

        if (ddlPageCount.Items.Count > 0)
        {
            ddlPageCount.SelectedIndex = 0;
        }
        refreshResult();
    }

    /// <summary>
    /// 清除查询条件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void cmdClear_Click(object sender, EventArgs e)
    {   //初始页码
        this.intPageNo = 0;

        this.hidDeAjaxDdlValue.Value = string.Empty;

        this.hidSupCustomer.Value = string.Empty;

        Session[WEBConstants.PAGE_NO_SESSION_ID + EM] = this.intPageNo.ToString();
        //初始化查询条件
        sc = new CDESearchCriteria(em);
        //sc.setSystemDefaultValue((Oprator)Session[CDEConstants.SESSION_LOIN_OPRATOR]);
        //初始化默认排序方式
        sc.setSystemDefaultSort();

        string ids;
        //添加查询条件
        ids = (string)Session[CDEConstants.CONST_SESSION_STRUCT_ITEM_IDS];
        if (ids != null && ids != string.Empty)
        {
            sc.addCondition("ID", ids, CDEConstCompare.Include);
        }
        //添加隐藏的默认查询条件
        sc.setHiddenDefaultValue(em, (Oprator)Session[CDEConstants.SESSION_LOIN_OPRATOR]);
        //添加默认查询条件
        sc.setDefaultValue(em, (Oprator)Session[CDEConstants.SESSION_LOIN_OPRATOR]);
        //子画面传过来的条件
        GetSubScCondition();

        dgmeisai.ListEntity = (List<CDEEntity>)Session[WEBConstants.LIST_SESSION_ID + EM];
        //查询条件绑定
        SearchDataBind();
        //页面显示条数初始化
        if (ddlPageCount.Items.Count > 0)
        {
            ddlPageCount.SelectedIndex = 0;
        }
        //刷新结果显示
        refreshResult();
    }

    /// <summary>
    /// 结果显示
    /// </summary>
    public void refreshResult()
    {
        txtPage.Text = "";

        Session[WEBConstants.SC_SESSION_ID + EM] = sc;
        //Session[CDEConstants.CONST_QUERYSTRING_BACK_SC] = sc;

        Session[WEBConstants.SC_SESSION_ID + EM + "DEA"] = hidDeAjaxDdlValue.Value;

        Session[WEBConstants.SC_SESSION_ID + EM + "CHO"] = this.hidSupCustomer.Value;

        sc.PageSize = int.Parse(ddlPageCount.SelectedValue);

        this.hidPageSize.Value = ddlPageCount.SelectedValue;

        this.hidPageStart.Value = sc.PageStart.ToString();

        //查询结果总条数

        if (em.Name == "ORDERS_MANAGER" || em.Name == "ORDERS_INQUIRY")
        {
            strAllPage = SqlQueryEntity.sqlQueryListCount(sc).ToString();
        }
        else
        {
            strAllPage = CDEService.LoadCount(em, sc);
        }

        this.hidAllSize.Value = strAllPage;

        Session[WEBConstants.ALLPAGE_SESSION_ID + EM] = strAllPage;
        //合计条数      
        this.lbl_count.Text = strAllPage;

        if (sc.PageStart > Convert.ToInt32(strAllPage))
        {

            sc.PageStart = sc.PageStart - sc.PageSize;
        }

        Session[WEBConstants.PAGE_NO_SESSION_ID + EM] = intPageNo.ToString();
        //查询结果
        selectEntities();
        //当前列表处理
        this.setCurList();
    }

    /// <summary>
    /// 分页设置
    /// </summary>
    protected void setPagesize()
    {
        string strDisplayCount = System.Configuration.ConfigurationManager.AppSettings["DISPLAY_RECORD_COUNT"];

        string[] aryDisplayCount = strDisplayCount.Split(',');

        for (int i = 0; i < aryDisplayCount.Length; i++)
        {
            if ("0".Equals(aryDisplayCount[i]))
            {
                this.ddlPageCount.Items.Add(new ListItem("全部", "0"));
            }
            else
            {
                this.ddlPageCount.Items.Add(new ListItem(aryDisplayCount[i]));
            }
        }
    }

    /// <summary>
    /// 当前列表处理
    /// </summary>
    private void setCurList()
    {
        strAllPage = (string)Session[WEBConstants.ALLPAGE_SESSION_ID + EM];
        
        intPageNo = int.Parse((string)Session[WEBConstants.PAGE_NO_SESSION_ID + EM]);
        //页面显示条数
        int pageCount = int.Parse(ddlPageCount.SelectedValue);

        int curPage = intPageNo + 1;
        //总页数
        int sumPageNo = 1;
        //最大页
        int maxPage = 1;
        
        if (pageCount != 0)
        {
            sumPageNo = int.Parse(strAllPage) / pageCount;

            maxPage = (int.Parse(strAllPage) + pageCount - 1) / pageCount;
        }
        //向前跳转显示
        if (intPageNo == 0)
        {
            this.btnPrePage.Enabled = false; 
        }
        else
        {
            this.btnPrePage.Enabled = true;
        }
        //向后跳转显示
        if (intPageNo == sumPageNo)
        {
            this.btnNextPage.Enabled = false;
        }
        else if (intPageNo == sumPageNo - 1 && (pageCount == 0 || int.Parse(strAllPage) % pageCount == 0))
        {
            this.btnNextPage.Enabled = false;
        }
        else
        {
            this.btnNextPage.Enabled = true;
        }
        strCurPage = curPage.ToString();

        StringBuilder sp = new StringBuilder();
        //最大页小于等于8时显示
        if (maxPage <= 9)
        {
            for (int i = 1; i <= maxPage; i++)
            {
                if (i == curPage)
                {
                    sp.Append("<li><span class=\"current\">").Append(i).Append("</span></li>");
                }
                else
                {
                    sp.Append("<li><a href=\"javascript:goPage(").Append(i).Append(")\">").Append(i).Append("</a></li>");
                }
            }
        }
        else
        {   //页数小于4的
            if (curPage <= 4)
            {
                for (int i = 1; i <= 4; i++)
                {
                    if (i == curPage)
                    {
                        sp.Append("<li><span class=\"current\">").Append(i).Append("</span></li>");
                    }
                    else
                    {
                        sp.Append("<li><a href=\"javascript:goPage(").Append(i).Append(")\">").Append(i).Append("</a></li>");
                    }
                }
                sp.Append("<li><a href=\"javascript:goPage(5)\">5</a></li>");
                sp.Append("<li>...</li>");
                sp.Append("<li><a href=\"javascript:goPage(").Append(maxPage - 2).Append(")\">").Append(maxPage - 2).Append("</a></li>");
                sp.Append("<li><a href=\"javascript:goPage(").Append(maxPage - 1).Append(")\">").Append(maxPage - 1).Append("</a></li>");
                sp.Append("<li><a href=\"javascript:goPage(").Append(maxPage).Append(")\">").Append(maxPage).Append("</a></li>");
            }
            else if (curPage >= maxPage - 3)
            {
                sp.Append("<li><a href=\"javascript:goPage(1)\">1</a></li>");
                sp.Append("<li><a href=\"javascript:goPage(2)\">2</a></li>");
                sp.Append("<li>...</li>");
                for (int i = maxPage - 4; i <= maxPage; i++)
                {
                    if (i == curPage)
                    {
                        sp.Append("<li><span class=\"current\">").Append(i).Append("</span></li>");
                    }
                    else
                    {
                        sp.Append("<li><a href=\"javascript:goPage(").Append(i).Append(")\">").Append(i).Append("</a></li>");
                    }
                }
            }
            else
            {
                sp.Append("<li><a href=\"javascript:goPage(1)\">1</a></li>");
                sp.Append("<li><a href=\"javascript:goPage(2)\">2</a></li>");
                sp.Append("<li>...</li>");

                for (int i = curPage - 1; i <= curPage + 2; i++)
                {
                    if (i == curPage)
                    {
                        sp.Append("<li><span class=\"current\">").Append(i).Append("</span></li>");
                    }
                    else
                    {
                        sp.Append("<li><a href=\"javascript:goPage(").Append(i).Append(")\">").Append(i).Append("</a></li>");
                    }
                }
                sp.Append("<li>...</li>");
                sp.Append("<li><a href=\"javascript:goPage(").Append(maxPage - 1).Append(")\">").Append(maxPage - 1).Append("</a></li>");
                sp.Append("<li><a href=\"javascript:goPage(").Append(maxPage).Append(")\">").Append(maxPage).Append("</a></li>");

            }
        }
        //显示页码
        pages.Text = sp.ToString();

        List<CDEEntity> newListEntity = (List<CDEEntity>)Session[WEBConstants.LIST_SESSION_ID + EM];
        //绑定数据源
        dgmeisai.ListEntity = newListEntity;
        //设定序号
        GetFirstNum();
        //数据绑定
        dgmeisai.DataBind();
        //排序显示
        dispSortImg();

    }
    /// <summary>
    /// 数据排序显示
    /// </summary>
    public void dispSortImg()
    {

        int index = 0;
        StringBuilder strsort = new StringBuilder();
        //为每一个attribute设置排序方式
        foreach (CDEAttribute attribute in sc.EntityManager.ListAttributes)
        {
            if (CDEConstants.ConstDispType_DISP.Equals(attribute.DISP_type)
                || CDEConstants.ConstDispType_READONLY.Equals(attribute.DISP_type))
            {
                index++;
                strsort.Append(",").Append(index).Append(",").Append(attribute.Name).Append(",");

                string sort = sc.getSortOrder(attribute.Name);
                if (!CDEConstants.IsEmpty(sort))
                {
                    //strsort.Append(",").Append(index).Append(",").Append(attribute.Name).Append(",").Append(sort);
                    strsort.Append(sort);
                }
                else
                {
                    strsort.Append("ASC");
                }
            }
        }
        if (strsort.Length > 0)
        {
            strsort.Remove(0, 1);
        }
        //排序的显示
        if (strsort.Length > 0)
        {
            StringBuilder sbr = new StringBuilder();
            sbr.AppendFormat("<script language=\"javascript\">{0}", Environment.NewLine);
            sbr.Append("show_sort(\"");
            sbr.Append(strsort.ToString());
            sbr.AppendFormat("\");{0}", Environment.NewLine);
            sbr.AppendFormat("</script>{0}", Environment.NewLine);
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "Sort", sbr.ToString());
        }
    }
    /// <summary>
    /// 页码修改
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ddlPageCount_SelectedIndexChanged(object sender, EventArgs e)
    {
        intPageNo = 0;
        Session[WEBConstants.PAGE_NO_SESSION_ID + EM] = intPageNo.ToString();
        txtPage.Text = "";
        sc.PageSize = int.Parse(ddlPageCount.SelectedValue);
        sc.PageStart = 1;
        this.hidPageStart.Value = sc.PageStart.ToString();
        this.hidPageSize.Value = ddlPageCount.SelectedValue;
        selectEntities();
        setCurList();
    }

    /// <summary>
    /// 查询结果Entities
    /// </summary>
    protected void selectEntities()
    {
        List<CDEEntity> listEntity;

        if (em.Full_Name == "WEB.ORDERS_MANAGER" || em.Full_Name == "WEB.ORDERS_INQUIRY")
        {
            listEntity = SqlQueryEntity.sqlQueryList(em, sc);
        }
        else 
        {
            listEntity = CDEService.LoadEntities(em, sc);
        }
        Session[WEBConstants.LIST_SESSION_ID + EM] = listEntity;
        rest.Text = "";
        if (listEntity.Count < 1)
        {
            rest.Text = "没有符合条件的信息";
        }
    }


    /// <summary>
    /// 上一页
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnPrePage_Click(object sender, EventArgs e)
    {
        intPageNo = int.Parse((string)Session[WEBConstants.PAGE_NO_SESSION_ID + EM]);
        intPageNo--;
        Session[WEBConstants.PAGE_NO_SESSION_ID + EM] = intPageNo.ToString();

        sc.PageStart = (intPageNo * sc.PageSize + 1);
        this.hidPageStart.Value = sc.PageStart.ToString();
        selectEntities();
        setCurList();
    }

    /// <summary>
    /// 下一页
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnNextPage_Click(object sender, EventArgs e)
    {
        intPageNo = int.Parse((string)Session[WEBConstants.PAGE_NO_SESSION_ID + EM]);
        intPageNo++;
        Session[WEBConstants.PAGE_NO_SESSION_ID + EM] = intPageNo.ToString();

        sc.PageStart = (intPageNo * sc.PageSize + 1);
        this.hidPageStart.Value = sc.PageStart.ToString();
        selectEntities();
        setCurList();

    }

    /// <summary>
    /// 页跳转
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnGO_Click(object sender, EventArgs e)
    {
        strAllPage = (string)Session[WEBConstants.ALLPAGE_SESSION_ID + EM];
        intPageNo = int.Parse((string)Session[WEBConstants.PAGE_NO_SESSION_ID + EM]);
        int pageCount = int.Parse(ddlPageCount.SelectedValue);
        int maxPage = 1;
        if (pageCount != 0)
        {
            maxPage = (int.Parse(strAllPage) + pageCount - 1) / pageCount;
        }

        if (!CDEConstants.IsEmpty(hidClickPage.Value))
        {
            txtPage.Text = hidClickPage.Value;
            hidClickPage.Value = "";
        }

        string strsp = txtPage.Text.Trim();
        if (Cit.CDE.Net.Module.Commons.NumberUtils.isNumber(strsp))
        {
            int intSp = int.Parse(strsp);
            if (intSp == 0)
            {
                return;
            }

            if (intSp >= maxPage)
            {
                intSp = maxPage;
                txtPage.Text = intSp.ToString();
            }

            intPageNo = intSp - 1;
            Session[WEBConstants.PAGE_NO_SESSION_ID + EM] = intPageNo.ToString();

            sc.PageStart = (intPageNo * sc.PageSize + 1);
            this.hidPageStart.Value = sc.PageStart.ToString();
            selectEntities();
            setCurList();
        }
    }

    /// <summary>
    /// 排序
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSort_Click(object sender, EventArgs e)
    {
        string aname = hidAName.Value;
        string asort = hidASort.Value;

        //Page init
        sc = (CDESearchCriteria)Session[WEBConstants.SC_SESSION_ID + EM];
        Session[WEBConstants.PAGE_NO_SESSION_ID + EM] = "0";
        sc.PageStart = 1;

        txtPage.Text = "";

        this.hidPageStart.Value = sc.PageStart.ToString();

        //sort reset
        sc.removeSortOrder(aname);
        string[] sort = new string[2];
        sort[0] = aname;
        if (CDEConstants.SORT_ASC.Equals(asort))
        {
            sort[1] = CDEConstants.SORT_DESC;
        }
        else
        {
            sort[1] = CDEConstants.SORT_ASC;
        }
        sc.ListSortOders.Insert(0, sort);

        hidAName.Value = "";
        hidASort.Value = "";

        selectEntities();
        setCurList();
    }

    /// <summary>
    /// 下拉检索条件数据初始化
    /// </summary>
    /// <param name="de_em"></param>
    private void initDEData(CDEEntityManager de_em)
    {
        if (!Cit.CDE.Net.Module.Commons.CDEConstants.IsEmpty(hidDeAjaxDdlValue.Value))
        {
            StringBuilder strBldr = new StringBuilder();
            strBldr.AppendFormat("<script language=\"javascript\">{0}", Environment.NewLine);
            strBldr.AppendFormat("initDEData();");
            strBldr.AppendFormat("</script>{0}", Environment.NewLine);

            Page.ClientScript.RegisterStartupScript(Page.GetType(), "confirm", strBldr.ToString());
        }
    }
    /// <summary>
    /// 获取当前首行号
    /// </summary>
    /// <returns></returns>
    public void GetFirstNum()
    {
        intPageNo = int.Parse((string)Session[WEBConstants.PAGE_NO_SESSION_ID + EM]);
        int pageCount = int.Parse(ddlPageCount.SelectedValue);
        _Num_HH = pageCount * (intPageNo) + 1;
        
    }
    /// <summary>
    /// 数据绑定
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dgmeisai_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        int index = e.Item.ItemIndex;
        if (index == -1 || dgmeisai.ListEntity == null || dgmeisai.ListEntity.Count < index) return;
        e.Item.Cells[0].Attributes.Add("style", "width:40px;");
        //设置鼠标滑动效果
        if (index % 2 == 0)
        {
            e.Item.Attributes.Add("class", "bgtr2");
            e.Item.Attributes.Add("onmouseover", "this.className='bgtr3'");
            e.Item.Attributes.Add("onmouseout", "this.className='bgtr2'");
        }
        else
        {
            e.Item.Attributes.Add("class", "bgtr1");
            e.Item.Attributes.Add("onmouseover", "this.className='bgtr3'");
            e.Item.Attributes.Add("onmouseout", "this.className='bgtr1'");
        }

        //MethodInfo mi = this.buttonArea.Page.GetType().GetMethod("itemDataBound"); //获取SetValue()方法
        
        //object[] per = new object[]{sender,e};   //建造输入参数
        
        //mi.Invoke(this.buttonArea.Page, per);    //调用SetValue方法


    }
    /// <summary>
    /// 子画面传过来的查询条件
    /// </summary>
    public void GetSubScCondition()
    {
        //子画面传过来的查询条件
        List<CDECriteria> list_Criteria = (List<CDECriteria>)Context.Items["list_Criteria"];
        if (list_Criteria != null)
        {
            foreach (CDECriteria criteria in list_Criteria)
            {
                sc.addCondition(criteria.Clm_name, criteria.Value, criteria.Compare);                
            }
        }

        List<CDESearchCriteria> list_CDESearchCriteria = (List<CDESearchCriteria>)Context.Items["list_CDESearchCriteria"];
        if (list_CDESearchCriteria != null)
        {
            sc.addORCondition(list_CDESearchCriteria.ToArray());
         
        }


    }
    /// <summary>
    /// 重新设置page数据
    /// </summary>
    public void refreshPage() 
    {
        strAllPage = Convert.ToString(Convert.ToInt32(Session[WEBConstants.ALLPAGE_SESSION_ID + EM]) - listIndex.Count);
        
        this.hidAllSize.Value = strAllPage;

        Session[WEBConstants.ALLPAGE_SESSION_ID + EM] = strAllPage;
        //合计条数      
        this.lbl_count.Text = strAllPage;

        intPageNo = int.Parse((string)Session[WEBConstants.PAGE_NO_SESSION_ID + EM]);

        if (sc.PageStart > Convert.ToInt32(strAllPage))
        {

            intPageNo = intPageNo - 1;
        }
    }



}
